SpringBoot官方文档翻译(二十):开发者工具

20. Developer Tools(开发者工具)

1
2
3
4
5
6
Spring Boot includes an additional set of tools that can     
make the application development experience a little more
pleasant. The spring-boot-devtools module can be included
in any project to provide additional development-time features.
To include devtools support, add the module dependency to
your build, as shown in the following listings for Maven and Gradle:

Spring Boot引入了额外的一些工具,让应用的开发体验变得更加愉快。spring-boot-devtools模块能够被任何项目引入提供“开发-时间”功能。如果需要支持devtools功能,增加如下模块到您的构建李,如下:
Maven:

1
2
3
4
5
6
7
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

Gradle:

1
2
3
dependencies {
compile("org.springframework.boot:spring-boot-devtools")
}

1
2
3
4
5
6
7
Developer tools are automatically disabled when running a      
fully packaged application. If your application is launched
from java -jar or if it is started from a special classloader,
then it is considered a “production application”. Flagging the
dependency as optional in Maven or using compileOnly in Gradle
is a best practice that prevents devtools from being transitively
applied to other modules that use your project.

当运行一个完整的应用jar包的时候,开发者工具集将会被自动禁用。如果您的应用是通过java -jar启动或者是通过一些特殊的类加载器启动的,它会被当做一个“产品级别的应用”。在Maven中标记devtools的依赖为可选的,在Gradle中使用compileOnly是防止devtools被传递依赖到您的其他模块的的最佳实践。

1
2
3
4
Repackaged archives do not contain devtools by default. If     
you want to use a certain remote devtools feature, you need
to disable the excludeDevtoolsbuild property to include it.
The property is supported with both the Maven and Gradle plugins.

重新打包的档案在默认情况下不包含devtools。如果您想使用某个远程的devtools功能,您需要禁用excludeDevtoolsbuild属性去支持它。这个属性既支持Maven也支持Gradle。

分享到